﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AccountingLibs;
using Lists;
using System.Linq;
//using System.Data.Objects;

namespace BasicForms
{
    public partial class DefaultLocalSettings : BasicForms.FrmOKCancel
    {
        public DefaultLocalSettings()
        {
            InitializeComponent();
        }

        private void DefaultLocalSettings_Load(object sender, EventArgs e)
        {
            #region cmbKho
            cmbKho.DataSource = DanhMucKho.Instance.DataView;
            cmbKho.DisplayColumn = "Ten";
            cmbKho.ValueColumn = "ID";
            cmbKho.AddVisibleColumn("Ma", "Mã");
            cmbKho.AddVisibleColumn("Ten", "Tên");
            #endregion

            #region cmbThueSuat
            cmbThueSuat.DataSource = DanhMucThueSuat.Instance.DataView;
            cmbThueSuat.DisplayColumn = "Ten";
            cmbThueSuat.ValueColumn = "ID";
            cmbThueSuat.AddVisibleColumn("Ma", "Mã");
            cmbThueSuat.AddVisibleColumn("Ten", "Tên");
            #endregion

            #region cmbPhuongThucThanhToanMuaHang
            cmbPhuongThucThanhToanMuaHang.DataSource = DanhMucPhuongThucThanhToanMuaHang.Instance.DataView;
            cmbPhuongThucThanhToanMuaHang.DisplayColumn = "Ten";
            cmbPhuongThucThanhToanMuaHang.ValueColumn = "ID";
            cmbPhuongThucThanhToanMuaHang.AddVisibleColumn("Ma", "Mã");
            cmbPhuongThucThanhToanMuaHang.AddVisibleColumn("Ten", "Tên");
            #endregion

            #region cmbPhuongThucThanhToanBanHang
            cmbPhuongThucThanhToanBanHang.DataSource = DanhMucPhuongThucThanhToanBanHang.Instance.DataView;
            cmbPhuongThucThanhToanBanHang.DisplayColumn = "Ten";
            cmbPhuongThucThanhToanBanHang.ValueColumn = "ID";
            cmbPhuongThucThanhToanBanHang.AddVisibleColumn("Ma", "Mã");
            cmbPhuongThucThanhToanBanHang.AddVisibleColumn("Ten", "Tên");
            #endregion

            cmbKho.EditValue = AccountingLibs.LocalSettings.HeThong.KhoID;
            cmbThueSuat.EditValue = AccountingLibs.LocalSettings.HeThong.ThueSuatID;
            cmbPhuongThucThanhToanMuaHang.EditValue = AccountingLibs.LocalSettings.HeThong.PhuongThucThanhToanMuaHangID;
            cmbPhuongThucThanhToanBanHang.EditValue = AccountingLibs.LocalSettings.HeThong.PhuongThucThanhToanBanHangID;
        }


        protected override void btnOK_Click(object sender, EventArgs e)
        {
           
            AccountingLibs.LocalSettings.HeThong.KhoID = (Guid)cmbKho.EditValue;
            AccountingLibs.LocalSettings.HeThong.ThueSuatID = (Guid)cmbThueSuat.EditValue;
            AccountingLibs.LocalSettings.HeThong.PhuongThucThanhToanMuaHangID = (Guid)cmbPhuongThucThanhToanMuaHang.EditValue;
            AccountingLibs.LocalSettings.HeThong.PhuongThucThanhToanBanHangID = (Guid)cmbPhuongThucThanhToanBanHang.EditValue;

            Close();
        }
    }
}
